 ;==================================================================;
 ;=  Module Name:  DESKTOP.ASM                                     =;
 ;=                                                                =;
 ;=  Module Description: Desktop                                   =;
 ;=                                                                =;
 ;=  Author:  Kreoton    04 Nov 2005                               =;
 ;=                                                                =;
 ;=  Revision History:                                             =;
 ;=                                                                =;
 ;=      Date         Version                                      =;
 ;=                                                                =;
 ;=      04/11/05     0.1                                          =;
 ;=        + Created                                               =;
 ;=                                                                =;
 ;=  Compile with FASM 1.64+                                       =;
 ;=                                                                =;
 ;==================================================================;

format PE GUI 4.0 at DefImageBase on '..\include\mx_stub.exe'
entry start

include '%fasminc%\win32a.inc'
;include "..\Include\macros.inc"
include "..\Include\data.inc"
include "..\Include\const.inc"
include "..\Include\struct.inc"

color2          = 0x336699

EventID_Redraw          = 1
EventID_Focus           = 2
EventID_LostFocus       = 3
EventID_Close           = 4
EventID_MouseEvent      = 5
EventID_Ctrl0           = 10
EventID_Ctrl1           = 11
EventID_Ctrl2           = 12
EventID_Ctrl3           = 13
EventID_Maximize        = 14
EventID_Restore         = 15
EventID_Kbd             = 20
EventID_IPC             = 50

section '.text' code readable executable

  start:

        call    [Get_screen_param]
        mov     [Screen_X],esi
        mov     [Screen_Y],edi
        shl     esi,16
        mov     si,di
        ; ESI = MaxX & MaxY
        
        push    dword ATTR_DeskTop
        push    dword my_name
        push    dword 0
        push    esi
        push    dword 0
        call    [DefineWindow]
        mov     [WinID],eax

        invoke  Draw_BLine, 0,0,[Screen_X],[Screen_Y],color2,[WinID]

        call    [End_of_redraw]

      Wait_Event:
        call    [WaitMessage]

        cmp     bh,EventID_LostFocus
        jne     no_EventID_LostFocus
        jmp     Wait_Event
      no_EventID_LostFocus:
        cmp     bh,EventID_Focus
        jne     no_EventID_Focus

        jmp     Wait_Event
      no_EventID_Focus:

        jmp     Wait_Event

ATTR_NoMove             = 0000000000000001b
ATTR_Top                = 0000000000000010b
ATTR_DeskTop            = 0000000000000100b
ATTR_NoCSize            = 0000000000001000b
ATTR_Unnormal           = 0000000000010000b
ATTR_MaxSize            = 0000000000100000b
ATTR_FastMenu           = 0000000001000000b

ATTR_CBttn_Close        = 0000000100000000b
ATTR_CBttn_Maximize     = 0000001000000000b
ATTR_CBttn_Minimize     = 0000010000000000b

section '.data' data readable writeable
  my_name       db 'Desktop',0
  PicFile       db 'logo.gif',0
  WinID         rd 1
  Screen_X      rd 1
  Screen_Y      rd 1
  picfile       rd 0x100000
        
section '.idata' import data readable writeable

;data import
;
; Import functions:
;

  library mx32,'mx32.dll'

  import mx32,\
         f1,'OneFunction',\
         VirtualAlloc,'VirtualAlloc',\
         VirtualProtect,'VirtualProtect',\
         VirtualFree,'VirtualFree',\
         CreateProcess,'CreateProcess',\
         ExitProcess,'ExitProcess',\
         CreateThread,'CreateThread',\
         ExitThread,'ExitThread',\
         TestKbdInput,'TestKbdInput',\
         PutChar,'PutChar',\
         PutChar2,'PutChar2',\
         PrintString,'PrintString',\
         Get_Position,'Get_Position',\
         Set_Position,'Set_Position',\
         Set_focus,'Set_focus',\
         Set_focusPID,'Set_focusPID',\
         Get_FileAddress,'Get_FileAddress',\
         Inkey,'Inkey',\
         SendMessage,'SendMessage',\
         ReceiveMessage,'ReceiveMessage',\
         WaitMessage,'WaitMessage',\
         GetPID,'GetPID',\
         DefineWindow,'DefineWindow',\
         DefineButton,'DefineButton',\
         Put_pixel,'Put_pixel',\
         Get_screen_param,'Get_screen_param',\
         Draw_BLine,'Draw_BLine',\
         Draw_Picture,'Draw_Picture',\
         Kill_Window,'Kill_Window',\
         Write_Text,'Write_Text',\
         Write_Hex,'Write_Hex',\
         Draw_StdWindow,'Draw_StdWindow',\
         StdHandler,'StdHandler',\
         Draw_hLine,'Draw_hLine',\
         Get_XYSize,'Get_XYSize',\
         Get_WinParams,'Get_WinParams',\
         End_of_redraw,'End_of_redraw',\
         Begin_xDraw,'Begin_xDraw',\
         Get_focus,'Get_focus',\
         Create_CheckButton,'Create_CheckButton',\
         Create_StdButton,'Create_StdButton'


section '.rsrc' resource data readable

  ; resource directory

  directory RT_ICON,icons,\
            RT_GROUP_ICON,group_icons,\
            RT_VERSION,versions

  ; resource subdirectories

  resource icons,\
           1,LANG_NEUTRAL,icon_data

  resource group_icons,\
           17,LANG_NEUTRAL,main_icon

  resource versions,\
           1,LANG_NEUTRAL,version

  icon main_icon,icon_data,'..\include\mx.ico'

  versioninfo version,\
          VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
          'FileDescription','Desktop',\
          'FileVersion','1.0',\
          'OriginalFilename','DESKTOP.EXE',\
          'InternalName','Desktop.exe',\
          'SpecialBuild',SpecialBuild,\
          'ProductName',ProductName,\
          'ProductVersion',ProductVersion,\
          'LegalCopyright',LegalCopyright,\
          'CompanyName',CompanyName,\
          'Comments',rsrcComments,\
          'LegalTrademarks',LegalTrademarks

section '.reloc' fixups data readable discardable
